home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 034a / prons.zip / PRONS.ASM next >
Assembly Source File  |  1991-11-01  |  14KB  |  480 lines

  1. page 66,132
  2.  
  3. ;
  4. ; Copyright 1987, 1989 Samuel H. Smith;  All rights reserved
  5. ;
  6. ; This is a component of the ProDoor System.
  7. ; Do not distribute modified versions without my permission.
  8. ; Do not remove or alter this notice or any other copyright notice.
  9. ; If you use this in your own program you must distribute source code.
  10. ; Do not use any of this in a commercial product.
  11. ;
  12.  
  13. ; ---------------------------------------------------------------------------
  14. ;  PRONS - NoScroll -
  15. ;     keep the top half of the screen from scrolling away
  16. ;     used by ProDOOR during file transfers.  it also preserves
  17. ;     COM port interrupt vectors and will drop carrier after
  18. ;     a specified number of clock ticks.
  19. ;
  20. ; This program works under TaskView and other environments that do
  21. ; not pass DOS or ANSI outputs to BIOS.
  22. ;
  23. ; Written: 30-dec-87 (rev. 20-jan-89)
  24. ;
  25.  
  26. ; ---------------------------------------------------------------------------
  27. ;   Macros
  28. ;
  29.  
  30. ; set interrupt vector to ds:dx
  31. setdsdx  macro vect,src
  32.    mov  ah,25h
  33.    mov  al,vect
  34.    int 21h
  35. endm
  36.  
  37. ; store vector into dword
  38. getesbx  macro vect,dest
  39.    mov  ah,35h
  40.    mov  al,vect
  41.    int  21h     ;changes es
  42. endm
  43.  
  44.  
  45. ; ---------------------------------------------------------------------------
  46. ;
  47. code segment
  48.                 assume  cs:code,ds:nothing,es:nothing,ss:nothing
  49.  
  50.                 org     80h
  51. tailLength      db      ?
  52. tail            db      ?
  53.  
  54.                 org     100h
  55. entryPoint:     jmp     startup
  56.  
  57. ; ---------------------------------------------------------------------------
  58. ;   Working storage
  59. ;
  60. copyright       db      13,10,'ProNS (C) 1988-1991 S.H.Smith; v3.4 11-01-91'
  61.                 db      13,10,26
  62.  
  63. old10Vector     dd      0               ;chain to original video handler
  64. retp3           dd      0               ;return-to-user pointer, videoTTY
  65.  
  66. old21Vector     dd      0               ;chain to original dos handler
  67. retp2           dd      0               ;return-to-user pointer, dosWrite
  68. retp1           dd      0               ;return-to-user pointer, dosConOut
  69.  
  70.  
  71. lastLine        db      24              ;last line of screen (0=first)
  72.  
  73. splitLine       db      3   ;18         ;line where the screen is split
  74.                                         ;(lastLine-scrollLines-1)
  75.     
  76. scrollLines     db      0               ;lines in scrolling region
  77.  
  78. defaltLines     = 23                    ;default lines in scrolling region
  79.  
  80. scrollColor     = 7                     ;display attrib in scrolling region
  81.  
  82.  
  83. ; ---------------------------------------------------------------------------
  84. ;   New handler for video interrupts
  85.  
  86. new10:          cmp     ah,14
  87.                 jz      videoTTY
  88.  
  89.                 cmp     ah,6
  90.                 jz      videoScroll
  91.  
  92. ;               cmp     ah,2
  93. ;               jz      videoSetPos
  94.  
  95. useOld10:       jmp     old10Vector     ;chain to other interrupts
  96.   
  97.               
  98. ; ---------------------------------------------------------------------------
  99. ; we have a set cursor position request; clip it to the scrolling area only
  100. ; (just let this happen; makes PCKERMIT and others look better)
  101. ;
  102. ;videoSetPos:    cmp     dh,splitLine
  103. ;                jge     useOld10
  104. ;
  105. ;                mov     dh,splitLine
  106. ;                jmp     useOld10
  107.  
  108.  
  109. ; ---------------------------------------------------------------------------
  110. ; we have a scroll request; clip it to the scrolling area only
  111. ;
  112. videoScroll:    cmp     ch,splitLine
  113.                 jge     useOld10
  114.  
  115.                 mov     ch,splitLine
  116.                 jmp     useOld10
  117.  
  118.  
  119. ; --------------------------------------------------------------------------
  120. ; process video TTY calls
  121. ;
  122. videoTTY:       cmp     al,10           ;linefeed?
  123.                 jnz     useOld10
  124.  
  125.  
  126. ; ---------------------------------------------------------------------------
  127. ; we have a linefeed request; if it will cause scrolling, 
  128. ; make sure the fixed lines stay where they are
  129. ;
  130. videoLineFeed:  push    ax
  131.                 push    bx
  132.                 push    cx
  133.                 push    dx
  134.                 push    ds
  135.                 push    es
  136.                 push    si
  137.                 push    di
  138.  
  139.                 mov     ah,3            ;get cursor position
  140.                 mov     bh,0
  141.                 int     10h
  142.                 cmp     dh,lastLine
  143.                 jz      vTrapScroll
  144. ;
  145. ; won't cause scroll, restore environ and pass back to bios
  146. ;
  147.                 pop     di
  148.                 pop     si
  149.                 pop     es
  150.                 pop     ds
  151.                 pop     dx
  152.                 pop     cx
  153.                 pop     bx
  154.                 pop     ax
  155.                 jmp     useOld10
  156.  
  157. ;
  158. ; the linefeed will cause scroll - scroll manually instead
  159. ;
  160. vTrapScroll:    mov     ah,6            ;scroll up
  161.                 mov     al,1            ;lines=1
  162.                 mov     bh,scrollColor  
  163.  
  164.                 mov     cl,0
  165.                 mov     ch,splitLine    ;top-left of scroll region
  166.  
  167.                 mov     dl,79
  168.                 mov     dh,lastLine     ;bottom-right of scroll region
  169.  
  170.                 int     10h
  171.  
  172.                 pop     di
  173.                 pop     si
  174.                 pop     es
  175.                 pop     ds
  176.                 pop     dx
  177.                 pop     cx
  178.                 pop     bx
  179.                 pop     ax
  180.                 pop     word ptr retp3  ;return to user code
  181.                 pop     word ptr retp3+2
  182.                 popf
  183.                 clc
  184.                 jmp     retp3
  185.  
  186.  
  187.  
  188. ; ===========================================================================
  189. ;   New handler for dos interrupts
  190.  
  191. new21:          cmp     ah,2
  192.                 jz      dosConOut
  193.  
  194.                 cmp     ah,40h
  195.                 jz      dosWrite
  196.  
  197. useOld21:       jmp     old21Vector     ;chain to other interrupts
  198.  
  199.              
  200.  
  201. ; ===========================================================================
  202. ; we have a write to file handle-1 request.  change it into repeated
  203. ; calls to dosConOut so linefeeds will be trapped
  204. ;
  205. dosWrite:       cmp     bx,1            ;stdout
  206.                 jz      trapWrite
  207.                 cmp     bx,2            ;stderr
  208.                 jz      trapWrite
  209.                 jmp     useOld21
  210.  
  211. trapWrite:      pop     word ptr retp2  ;pointer to user code
  212.                 pop     word ptr retp2+2
  213.                 popf
  214.  
  215.                 push    bx
  216.                 push    cx
  217.                 push    dx
  218.                 push    ds
  219.                 mov     bx,dx
  220.  
  221. writeChar:      cmp     cx,0
  222.                 jz      endWrite
  223.  
  224.                 push    bx
  225.                 push    cx
  226.                 mov     dl,[bx]
  227.                 mov     ah,2            ;use dos dosConOut function
  228.                 int     21h             ;on each char in the buffer
  229.                 pop     cx
  230.                 pop     bx
  231.  
  232.                 inc     bx
  233.                 dec     cx
  234.                 jmp     writeChar
  235.  
  236. endWrite:       pop     ds
  237.                 pop     dx
  238.                 pop     cx
  239.                 pop     bx
  240.                 mov     ax,cx           ;return as though all bytes written
  241.                 clc
  242.                 jmp     retp2
  243.  
  244.  
  245. ; ===========================================================================
  246. ; process console output calls
  247. ;
  248. dosConOut:      cmp     dl,10           ;linefeed?
  249.                 jnz     useOld21
  250.  
  251.  
  252. ; ---------------------------------------------------------------------------
  253. ; we have a linefeed request; if it will cause scrolling, 
  254. ; make sure the fixed lines stay where they are
  255. ;
  256. dosLineFeed:    push    ax
  257.                 push    bx
  258.                 push    cx
  259.                 push    dx
  260.                 push    ds
  261.                 push    es
  262.                 push    si
  263.                 push    di
  264.  
  265.                 mov     ah,3            ;get cursor position
  266.                 mov     bh,0
  267.                 int     10h
  268.                 cmp     dh,lastLine
  269.                 jz      dTrapScroll
  270. ;
  271. ; won't cause scroll, restore environ and pass back to dos
  272. ;
  273.                 pop     di
  274.                 pop     si
  275.                 pop     es
  276.                 pop     ds
  277.                 pop     dx
  278.                 pop     cx
  279.                 pop     bx
  280.                 pop     ax
  281.                 jmp     useOld21
  282.  
  283. ;
  284. ; the linefeed will cause scroll - scroll manually instead
  285. ;
  286. dTrapScroll:    mov     ah,6            ;scroll up
  287.                 mov     al,1            ;lines=1
  288.                 mov     bh,scrollColor  
  289.  
  290.                 mov     cl,0
  291.                 mov     ch,splitLine    ;top-left of scroll region
  292.  
  293.                 mov     dl,79
  294.                 mov     dh,lastLine     ;bottom-right of scroll region
  295.  
  296.                 int     10h
  297.  
  298.                 pop     di
  299.                 pop     si
  300.                 pop     es
  301.                 pop     ds
  302.                 pop     dx
  303.                 pop     cx
  304.                 pop     bx
  305.                 pop     ax
  306.                 pop     word ptr retp1  ;return to user code
  307.                 pop     word ptr retp1+2
  308.                 popf
  309.                 clc
  310.                 jmp     retp1
  311.  
  312.  
  313.  
  314. ; ===========================================================================
  315. ;  startup entry point
  316. ; is noScroll already in memory?
  317. ;
  318. startup:        getesbx  10h            ;es:bx <- original cs
  319.                 mov     bx,offset copyright
  320.  
  321. checkPresent:   mov     al,cs:[bx]      ;get next byte from copyright message
  322.                 cmp     al,26           ;end of message?
  323.                 jz      unInstall       ;already present if so
  324.  
  325.                 cmp     al,es:[bx]      ;compare next byte to handler in chain
  326.                 jz      checkNext
  327.                 jmp     newInstall      ;new installation if mismatch
  328.  
  329. checkNext:      inc     bx              ;got a match, try the next char
  330.                 jmp     checkPresent
  331.  
  332.  
  333. ; ---------------------------------------------------------------------------
  334. ; already in memory - uninstall and exit
  335. ;
  336.                 assume  ds:nothing
  337. unInstall:
  338.                 lds     dx,es:old10Vector
  339.                 setdsdx 10h
  340.  
  341.                 lds     dx,es:old21Vector
  342.                 setdsdx 21h
  343. ;
  344. ; deAllocate the memory used by ProNS
  345. ;
  346.                 push    es
  347.                 mov     es,es:2ch       ;dealloc the tsr's environment segment
  348.                 mov     ah,49h          
  349.                 int     21h
  350.  
  351.                 pop     es              ;dealloc the tsr's code segment
  352.                 mov     ah,49h          
  353.                 int     21h
  354.  
  355.                 mov     ax,4ch          ;terminate process
  356.                 int     21h
  357.  
  358.  
  359. ; ---------------------------------------------------------------------------
  360. ; install noScroll
  361. ;
  362. newInstall:
  363.                 xor     ch,ch
  364.                 mov     cl,tailLength
  365.                 lea     si,tail
  366.  
  367. nextTail:
  368.                 jcxz    checkEga
  369.  
  370.                 lodsb
  371.                 dec cx
  372.  
  373.                 cmp     al,'0'
  374.                 jl      nextTail
  375.                 cmp     al,'9'
  376.                 jg      nextTail
  377.                 sub     al,'0'
  378.  
  379.                 mov     ah,scrollLines
  380.                 add     ah,ah           ;*2
  381.                 add     ah,ah           ;*4
  382.                 add     ah,scrollLines  ;*5
  383.                 add     ah,ah           ;*10
  384.                 add     al,ah
  385.                 mov     scrollLines,al
  386.                 jmp     nextTail
  387.  
  388. checkEga:
  389.                 mov     ax,40h
  390.                 mov     es,ax           ;is ega present and active?
  391.                 test    byte ptr es:[87h],8
  392.                 jnz     notEga
  393.  
  394.                 mov     ax,01130h
  395.                 xor     bx,bx           ;get last screen line
  396.                 mov     dl,lastLine     ;default to normal setting
  397.                 int     10h
  398.                 mov     lastLine,dl
  399.  
  400. notEga:
  401.                 ;verify that scrollLines is in range, use default if not
  402.                 mov     ah,scrollLines
  403.                 cmp     ah,lastLine
  404.                 jg      defaultScroll
  405.                 cmp     ah,2
  406.                 jle     defaultScroll
  407.                 jmp     scrollOK
  408.  
  409. defaultScroll:
  410.                 mov     ah,defaltLines
  411.  
  412. scrollOK:
  413.                 mov     scrollLines,ah
  414.                 mov     al,lastLine
  415.                 sub     al,ah
  416.                 inc     al
  417.                 mov     splitLine,al
  418.  
  419.                 getesbx  10h
  420.                 mov  word ptr [old10Vector+0],bx
  421.                 mov  word ptr [old10Vector+2],es
  422.  
  423.                 getesbx  21h
  424.                 mov  word ptr [old21Vector+0],bx
  425.                 mov  word ptr [old21Vector+2],es
  426.  
  427. ;
  428. ; prepare screen
  429. ; make sure the original cursor is below the split line
  430. ;
  431. prepare_scr:    mov     ah,2            ;linefeed once
  432.                 mov     dl,10
  433.                 int     21h
  434.  
  435.                 mov     ah,3            ;get cursor position
  436.                 mov     bh,0
  437.                 int     10h
  438.                 cmp     dh,splitLine
  439.                 jl      prepare_scr
  440. ;
  441. ; make sure the original cursor line is above the split line
  442. ;
  443.                 xor     ch,ch
  444.                 mov     cl,scrollLines
  445.                 dec     cl
  446.                 dec     cl
  447.  
  448. moveDown:       mov     ah,2
  449.                 mov     dl,10
  450.                 push    cx
  451.                 int     21h
  452.                 pop     cx
  453.                 loop    moveDown
  454.  
  455.                 mov     ah,2            ;set cursor position
  456.                 mov     bh,0
  457.                 mov     dh,splitLine
  458.                 mov     dl,0
  459.                 int     10h
  460.  
  461. ;
  462. ; vector in the new handler
  463. ;
  464.                 assume  ds:code
  465.                 push    cs
  466.                 pop     ds
  467.                 
  468.                 mov     dx,offset new10
  469.                 setdsdx 10h
  470.  
  471.                 mov     dx,offset new21
  472.                 setdsdx 21h
  473.  
  474.                 mov     dx,offset startup       ;last resident byte
  475.                 int     27h                     ;terminate and stay resident
  476.  
  477. code ends
  478.                 end entryPoint
  479.  
  480.